/**
 * 
 */
package cn.gov.msa.util;

import java.util.Properties;

import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.EncodedResource;
import org.springframework.core.io.support.PropertiesLoaderUtils;

/**
 * @Title: PropertiesTools.java
 * @Package cn.gov.msa.util
 * @Description: TODO(用一句话描述该文件做什么)
 * @author 何宇江
 * @date 2018年2月22日 下午2:15:42
 */
public class PropertiesTools {
	public static String readProperties(String key) {
		String value = "";
		
		try{
	        EncodedResource encodedResource = new EncodedResource(new ClassPathResource("common.properties"), "UTF-8");
//	        Resource resource = new ClassPathResource("common.properties");  
	        Properties props = PropertiesLoaderUtils.loadProperties(encodedResource);  
	        value = props.getProperty(key);    
		}
		catch(Exception e){
			e.printStackTrace();
		}
		
        return value;
	}
	
	public static String wechatProperties(String key) {
		String value = "";
		
		try{
			Resource resource = new ClassPathResource("wechat.properties");  
			Properties props = PropertiesLoaderUtils.loadProperties(resource);  
			value = props.getProperty(key);    
		}
		catch(Exception e){
			e.printStackTrace();
		}
		
		return value;
	}
	
	public static void main(String[] args) throws Exception {
//		PropertiesTools.readProperties();
	}
}
